extends CharacterBody2D

@onready var pt = preload("res://ston/炮台.tscn")

@export var zd : PackedScene

func _ready() -> void:
	print("玩家",self)
	#var _pt = pt.instantiate()
	#var img = load("res://image/Retina/tankGreen_barrel1.png")
	#if img:
		#_pt.texture = img
	#else:
		#print("加载图片失败")
	#_pt.open_fire.connect(open_fire)
	#add_child(_pt)

func open_fire(wz:Vector2,fx :float):
	var _zd = zd.instantiate()
	_zd.SD = 1000
	get_tree().root.add_child(_zd)
	_zd.position = wz
	_zd.rotation = fx + PI
	_zd.fire(Vector2.RIGHT.rotated(fx + PI/2))



func move_up():
	position.y -= 10
	$Di_pan.rotation = PI

func move_down():
	position.y += 10
	$Di_pan.rotation = 0

func move_left():
	position.x -= 10
	$Di_pan.rotation = -PI/2

func move_right():
	position.x += 10
	$Di_pan.rotation = PI/2
